<template>
  <div>
    <pre v-html="data"></pre>
    <el-row >
      <el-col :span="2" style="margin-left: 85px">
        <span>国家</span>
      </el-col>
      <el-col :span="5">
        <el-select
          filterable
          size="mini"
          style="margin-bottom: 15px; max-width: 100%"
          v-model="$store.state.edit.row.countryId"
          placeholder="请选择目的国家"
          @change="countryStateSourceSelect"
        >
          <el-option
            v-for="(item, value) in $store.state.edit.entry.sources.countryNameCnSource"
            :key="value"
            :label="item"
            :value="Number(value)"
          />
        </el-select>
      </el-col>
    </el-row>
    <el-row >
      <el-col :span="2" style="margin-left: 85px">
        <span>国内分区</span>
      </el-col>
      <el-col :span="5">
        <el-select
          v-model="$store.state.edit.row.provinceId"
          placeholder="请选择国内分区"
          clearable
          filterable
          size="mini"
          style="margin-bottom: 15px; max-width: 100%"
        >
          <el-option
            v-for="(k, v) in countryStateSource"
            :key="k"
            :label="countryStateSource[v]"
            :value="Number(v)"
          ></el-option>
        </el-select>
      </el-col>
    </el-row>
    <!--<el-input v-model="id" value="$store.state.edit.row.id" type="hidden"></el-input>-->
  </div>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";

export default {
  props: ["data"],
  data() {
    return {
      countryId: this.$store.state.edit.row.countryId,
      provinceId: this.$store.state.edit.row.provinceId,
      //国内分区
      countryStateSource: {},
    };
  },
  mounted() {
    this.countryStateSourceSelect();
  },
  methods: {
    countryStateSourceSelect() {
      var data = {};
      data["countryId"] = this.$store.state.edit.row.countryId;
      ajax("countryStateSourceSelect", data).then(
        res => {
          if (res.code===200){
            this.countryStateSource = res.data;
          }else{
            if (res.message){
              this.$message.error(res.message);
            }else {
              this.$message.error('生成鉴权token失败!');
            }
          }
        },
        error => {
          console.log(error);
        }
      );
    }
  }
};
</script>
